{extend name="layout/iframe" /}
{block name="pagecss"}
<style>
    .layui-form-select .layui-input{
        padding-right: 0;
        cursor: pointer;
    }
</style>
{/block}
{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>优惠券类型</label>
            <div class="layui-input-block">
                <select name="coupon_type" lay-filter="type" id="coupon_type" lay-verify="coupon_type">
                    <option value="0">请选择</option>
                    {foreach $type as $k => $v}
                    <option value="{$k}" {if $info.coupon_type == $k} selected {/if}>{$v}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item {if  $info.coupon_type == 1 || $info.coupon_type == 3|| $info.coupon_type == 4|| $info.coupon_type == 6} layui-hide {/if} productType">
            <label class="layui-form-label"><span class="required">*</span>选择品类</label>
            <div class="layui-input-inline">
                <div class="layui-form-item">
                    {foreach $category as $v}
                    <input class="category" style="width: 100%;" type="checkbox" name="category_id[]" lay-skin="primary" title="{$v.name}" value="{$v.id}" {if  in_Array($v.id , $categors)  } checked {/if} >
                    {/foreach}
                </div>
            </div>
        </div>

        <div class="layui-form-item {if  $info.coupon_type == 1 || $info.coupon_type == 2|| $info.coupon_type == 4|| $info.coupon_type == 5} layui-hide {/if} product">
            <label class="layui-form-label"><span class="required">*</span>选择优惠商品</label>
            <div class="layui-input-block">
                <button class="layui-input" lay-event="purchase-o" id="product_name" type="button"  data-title="选择">{$product.name}</button>
                <input type="hidden" name="product_id" id="product_id" value="{$product.id}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>优惠券名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="name" lay-verify="name" placeholder="请输入" autocomplete="off" value="{$info.name}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>优惠券用途</label>
            <div class="layui-input-block">
                <select name="coupon_purpose" id="coupon_purpose" lay-filter="coupon_purpose" lay-verify="required">
                    <option value=""></option>
                    {foreach $purpose as $k => $v}
                    <option value="{$k}" {if $info.coupon_purpose == $k} selected {/if}>{$v}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item {if $info.coupon_purpose == 1 || $info.coupon_purpose == 0} layui-hide {/if} number">
            <label class="layui-form-label"><span class="required">*</span>优惠券数量</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="number" lay-verify="number" placeholder="请输入" autocomplete="off" value="{$info.number}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>开始日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="start_time" placeholder="yyyy-MM-dd" name="start_time" lay-verify="required" value="{$info.start_time}">
            </div>　　
            <label class="layui-form-label" style="width: 20%"><span class="required">*</span>结束日期</label>
            <div class="layui-input-inline" >
                <input type="text" class="layui-input" id="end_time" placeholder="yyyy-MM-dd" name="end_time" lay-verify="required" value="{$info.end_time}">
            </div>
        </div>

        <div class="layui-form-item threshold">
            <label class="layui-form-label">使用门槛</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="threshold" lay-verify="threshold"  value="{$info.threshold}" placeholder="元" autocomplete="off" >
            </div>
        </div>

        <div class="layui-form-item {if $info.coupon_type == 4 || $info.coupon_type == 5 || $info.coupon_type == 6} layui-hide {/if} amount">
            <label class="layui-form-label"><span class="required">*</span>抵现金额</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="cash_amount" lay-verify="cash_amount" value="{$info.cash_amount}" placeholder="元" autocomplete="off" >
            </div>
        </div>

        <div class="layui-form-item {if $info.coupon_type == 1 || $info.coupon_type == 2 || $info.coupon_type ==3} layui-hide {/if} strength">
            <label class="layui-form-label"><span class="required">*</span>折扣力度</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="discount_strength"  placeholder="折" value="{$info.discount_strength}" autocomplete="off">
            </div>
        </div>

        <input type="hidden" id="id" name="id" value="{$info.id}">
        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button class="layui-btn" type="button" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="token_url" value="{:url('admin/Image/token')}">
<input type="hidden" class="record_url" value="{:url('admin/Image/record')}">
<input type="hidden" class="delimage_url" value="{:url('admin/Image/delete')}">
<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/editPost')}">
<input type="hidden" class="get_product_url" value="{:url('admin/'.strtolower($model).'/get_product')}">
<input type="hidden" class="handle_url" value="{:url('admin/'.strtolower($model).'/handle')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/pages/js/promotion.js" type="text/javascript"></script>
{/block}